from queue import Queue
class CombinationSolution:
    def __init__(self,N_,R_):
        self.N = N_
        self.R = R_
    
    def index2vec(self,index:int)->list:
        pass
    
    def vec2index(self,vec:list)-> int:
        pass

class CombinationQuestions:
    def __init__(self,N_,R_):
        self.N = N_
        self.R = R_
        self.ans = []
        self.questions = []
        self.create_data()
    def create_data(self):
        ##
        self.create_all_combinations()
    def create_all_combinations(self):
        self.start =0
        cur = []
        self.help(cur,1)
    def help(self,cur:list,k:int):
        if len(cur)==self.R:
            new_combination = [i for i in cur]
            self.questions.append(new_combination)
            self.ans.append(self.start)
            self.start += 1
            return
        else:
            for i in range(k,self.N - self.R + len(cur) + 2):
                cur.append(i)
                self.help(cur,i+1)
                cur.pop()
    def justify(Solution):
        ans1 = self.ans.pop(0)
        que1 = self.questions.pop(0)

        ans2 = Solution.vec2index(que1)
        que2 = Solution.index2vec(ans1)

        if ans2 != ans1:
            print("The index of the combination: ",que1,"\n is wrong.\nThe real answer is: ",ans1," .But get: ",ans2)
            return False
        if not self.justify2vec(que1,que2):
            print("The combination of the index is: ",ans1,"\n",que1,"\n",que2)
    def justify2vec(self,que1:list,que2:list):
        for i,j in zip(que1,que2):
            if i!= j:
                return False
        return True

    def empty(self):
        return len(self.ans)==0